<?php
	if( isset($_POST["nick"]) && 
		isset($_POST["post"]) &&
		$_POST["post"] != "") {
		
		$nick = ($_POST['nick'] != "")? $_POST['nick'] : 'Anonymous';
		$post = $_POST['post'];
		$date = date("H:i - Y F j", time());
		
		$str = "$nick#$date#$post\n";
		
		$posts = file('posts.txt');
		$posts = array_merge(array($str), $posts);
		$fd = fopen('posts.txt', 'w');
		foreach($posts as $post){
			fwrite($fd, "$post");
		}
		fclose($fd);
	}
	header('Location:index.php');
?>		
		